<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理员主页</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    <!-- layui的水平导航 -->
    <div class="layui-header">
        <div class="layui-logo"><strong>高校健康上报后台管理系统</strong></div>
    </div>

    <!-- layui的垂直导航 -->
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item">
                    <a href="/admin1"><i class="layui-icon layui-icon-home"></i>  管理员主页</a>
                </li>
                <li class="layui-nav-item layui-this">
                    <a href="/userMange"><i class="layui-icon layui-icon-user"></i>  用户管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/numberMange"><i class="layui-icon layui-icon-password"></i>  账号管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/riskareaMange"><i class="layui-icon layui-icon-fire"></i>  风险地区管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/adminMange"><i class="layui-icon layui-icon-user"></i>  管理员账号管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/logout"><i class="layui-icon layui-icon-logout"></i>  退出系统</a>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <div style="padding: 15px;">
            <div class="demoTable">
                查询条件:
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="username" placeholder="请输入用户账号" autocomplete="off">
                </div>
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="name" placeholder="请输入用户姓名" autocomplete="off">
                </div>
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="type" placeholder="请输入用户身份" autocomplete="off">
                </div>
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="campus" placeholder="请输入用户校区" autocomplete="off">
                </div>
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="address" placeholder="请输入用户地址" autocomplete="off">
                </div>
                <button class="layui-btn" id="selectByCondition" data-type="reload">查询</button>
                <a href="/notreport"><button class="layui-btn">未打卡名单</button></a>
            </div>
            <table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>
        </div>
    </div>
    <script src="../layui/layui.js"></script>
    <script type="text/html" id="btn">
        <a class="layui-btn layui-btn-xs" lay-event="edit" href="/details/{{d.id}}">详情</a>
    </script>
    <script>
        layui.use('element', function(){
            var element = layui.element;

        });

        layui.use('table', function(){
            var table = layui.table;
            table.render({
                elem: '#LAY_table_user'
                ,url:'/mangeuser'
                ,cellMinWidth: 80
                ,toolbar:true
                ,title:'用户数据表'
                ,totalRow:true
                ,cols: [
                    [
                        {field:'id', title: 'ID', sort:true}
                        ,{field:'username', title: '用户', sort:true}
                        ,{field:'name', title: '姓名'}
                        ,{field:'idtype', title: '证件类型'}
                        ,{field:'idnumber', title: '证件号码'}
                        ,{field:'type', title: '身份'}
                        ,{field:'campus', title: '校区'}
                        ,{field:'address', title: '地址'}
                        ,{field:'telnumber', title: '电话号码'}
                        ,{field:'emcontact', title: '紧急联系人'}
                        ,{field:'emctelnumber', title: '紧急联系人方式'}
                        ,{field:'health', title: '身体状况'}
                        ,{field:'reportstatus', title: '打卡状态'}
                        ,{field: 'button', title: '操作', toolbar:"#btn"}
                    ]
                ]
                ,id: 'testReload'
            });
            var $ = layui.$, active = {
                reload: function(){
                    var username = $('#username');
                    var name = $('#name');
                    var type = $('#type');
                    var campus = $('#campus');
                    var address = $('#address');
                    console.log("key:" + username.val());
                    table.reload('testReload', {
                            url: '/selectUserByCondition'
                            ,where: {
                                username: username.val(),
                                name:name.val(),
                                type:type.val(),
                                campus:campus.val(),
                                address:address.val(),
                            }
                        }
                    );
                }
            };
            $('.demoTable .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</div>
</body>
</html>